1. Field of the Invention
The present invention relates to disk drives for computer systems. More particularly, the present invention relates to a disk drive employing thresholds for cache memory allocation.
2. Description of the Prior Art
A disk drive typically comprises a cache memory for caching data written to the disk as well as data read from the disk. The overall performance of the disk drive is affected by how efficiently the cache memory can be allocated for a host command. In the past, the cache memory has been divided into cache segments each comprising a number of blocks (e.g., eight blocks), wherein the cache system would allocate a number of cache segments to process the host command. This technique is inefficient, however, if the number of blocks in a cache segment does not integer divide into the number of blocks associated with processing the host command leaving part of a cache segment allocated but unused.
The present invention may be regarded as a disk drive comprising a disk comprising a plurality of tracks, each track comprising a plurality of blocks. A head is actuated radially over the disk, and a semiconductor memory comprising a cache buffer caches data written to the disk and data read from the disk. The cache buffer comprises a plurality of segment pools, wherein each segment pool comprises a plurality of cache segments, each cache segment comprises at least one block, and the number of blocks in each cache segment varies between segment pools. A threshold is associated with a first one of the segment pools and a second one of the segment pools, wherein the threshold is greater than a size of the cache segments in the first segment pool and less than a size of the cache segments in the second segment pool. The disk drive receives a host command from a host computer, the host command comprising a command size indicating a number of blocks associated with the host command. A factor of the command size is compared to the threshold in order to allocate a cache segment from either the first segment pool or the second segment pool.
In one embodiment, a cache segment from the second segment pool is allocated if the factor of the command size is greater than the threshold. If the second segment pool is empty, in one embodiment a plurality of cache segments are allocated from the first segment pool.
In another embodiment, a cache segment from the first segment pool is allocated if the factor of the command size is less than the threshold. If the first segment pool is empty, in one embodiment a cache segment is allocated from the second segment pool.
In one embodiment, each cache segment comprises 2k number of blocks where k is a predetermined integer for each segment pool. For example, in one embodiment the segment pools comprise a one-block segment pool, an eight-block segment pool, a sixteen-block segment pool, and a sixty-four-block segment pool. A first factor of the command size is compared to a first threshold in order to allocate a cache segment from the one-block segment pool or the eight-block segment pool. A second factor of the command size is compared to a second threshold in order to allocate a cache segment from the eight-block segment pool or the sixteen-block segment pool. And a third factor of the command size is compared to a third threshold in order to allocate a cache segment from the sixteen-block segment pool or the sixty-four-block segment pool. In one embodiment, the first threshold is four, the second threshold is ten, and the third threshold is sixty-three.
In yet another embodiment, the threshold is adjusted relative to an allocation status of each cache segment in the segment pools. For example, the threshold is reduced if the number of free cache segments in the first segment pool falls below a predetermined threshold.
The present invention may also be regarded as a method of writing data through a head actuated radially over a disk in a disk drive. The disk comprises a plurality of tracks, each track comprising a plurality of blocks. The disk drive comprises a semiconductor memory having a cache buffer for caching data written to the disk and data read from the disk, the cache buffer comprising a plurality of segment pools, each segment pool comprising a plurality of cache segments, each cache segment comprises at least one block, and the number of blocks in each cache segment varies between segment pools. A threshold is associated with a first one of the segment pools and a second one of the segment pools, wherein the threshold is greater than a size of the cache segments in the first segment pool and less than a size of the cache segments in the second segment pool. A host command is received from a host computer, wherein the host command comprises a command size indicating a number of blocks associated with the host command. A factor of the command size is compared to the threshold in order to allocate a cache segment from either the first segment pool or the second segment pool.